package com.itheima.mapper;

import com.itheima.dto.FlavorDto;
import com.itheima.pojo.Dish;
import com.itheima.pojo.DishFlavor;
import com.itheima.vo.DishByIdVo;
import com.itheima.vo.DishListVo;
import com.itheima.vo.DishVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository//声明是个bean
public interface DishMapper {
    //添加菜品
    //结果指的是，当前sql的作用行
    //添加菜品
    int addDish(@Param("dish") Dish dish);

    //添加口味
    int adddishFlavor(@Param("dishFlavor") DishFlavor dishFlavor);

    //批量添加
    int batchInsertFlavor(@Param("list") List<DishFlavor> list);

    //菜品分页
    List<DishVo> page(@Param("name") String name, @Param("start") Integer start, @Param("pageSize") Integer pageSize);

    //计算 total(总条数)
    long countDish();

    //菜品下拉列表
    List<DishListVo> getlist(String categoryId);

    //根据id查询菜品信息
    DishByIdVo getDishById(String id);

    //根据id查找菜品口味
    List<FlavorDto> dishFlavorById(String id);

    //修改菜品
    int updateDish(Dish dish);


    //根据菜品id删除关联的口味
    int removeFlavorByDishId(String dishID);

    //根据菜品id查询有几条口味信息
    int countFlavorByDishId(String dishId);

    //删除菜品
    boolean deleteDish(List<String> ids);
    //删除菜品对应口味
    int deleteDishFlavor(List<String> ids);

    //菜品停售/起售
    boolean status(@Param("status") Integer status, @Param("ids") List<String> ids);

    List<DishListVo> getMobileList(@Param("categoryId") String categoryId, @Param("status") Integer status, @Param("page") Integer page, @Param("pageSize") Integer pageSize);
}
